<?php
namespace Admin\Controller;
use Think\Controller;
class ActivityController extends Controller {
    public function index(){
        $this->display();
    }
    public function activitylist(){
		
		$activitymodel=M('activity');
		$activitys=$activitymodel->order('aid ')->select();
		$this->activity=$activitys;
		$this->display();
	}
	public function delactivity($aid){
	$activitymodel=M('activity');	
	if (false!==$activitymodel->where("aid=$aid")->delete()) {
            $this->success('删除成功！');
        } else {
            $this->error('删除失败');
        }
		
	}
    public   function acadd(){
        // $aname=$_POST['aname'];
        // $adate=$_POST['adate'];
        // $aplace=$_POST['aplace'];
        // $charge=$_POST['charge'];
        // $atel=$_POST['atel'];
        // $acontent=$_POST['acontent'];
        // $activitymodel=M('activity');
        // if ($activitymodel->create()) {
            
        //     if (false !==$activitymodel->add()) {
        //         //echo $user->getLastSql();
        //         $this->success('添加成功！', 'activitylist');
        //     }
        //     else
        //     {
        //         $this->error('添加失败','activitylist');
        //     }
        // }
        // }



        $activitys = D('activity'); 
        $data['aname']=I('post.aname');
        $data['adate']=I('post.adate');
        $data['aplace']=I('post.aplace');
        $data['charge']=I('post.charge');
        $data['atel']=I('post.atel');  
        $data['acontent']=I('post.acontent');
        // $data['aid']=S('aid');
        dump($data);
        
         if(false!==$activitys->add($data)){
             $this->success('成功','activitylist');
         }else{
            $this->error('失败','activitylist');
         }
        }

        public   function editac(){

              $activitys = D('activity'); 
              $aid=I('post.aid');
        $data['aname']=I('post.aname');
        $data['adate']=I('post.adate');
        $data['aplace']=I('post.aplace');
        $data['charge']=I('post.charge');
        $data['atel']=I('post.atel');  
        $data['acontent']=I('post.acontent');
        dump($data);
        if(false !== $activitys->where("aid=$aid")->save($data)){
            $this->success('成功','activitylist');
         }else{
            $this->error('失败');
         }
        }
        public function edit(){    
            $activitys = D('activity'); 
            $aid=$_GET['aid'];
            $res= $activitys->where("aid=$aid")->find();
            $this->activity=$res;
         
        $this->display();
        }
}